<?php
namespace Home\Controller;
use Think\Controller;
class PersonController extends Controller{
	//通过json 获取所有的person信息
	public function findAllPerson(){
    	$personModel = M('Person');
    	$personList = $personModel->select();
    	$this->ajaxReturn($personList);
    }
    
    public function deleteById(){
    	$personModel = M('Person');
    	$id = $_POST['id'];
    	$result = $personModel->delete($id);
    	if($result){
    		$this->ajaxReturn('success');
    		return ;
    	}else {
    		$this->ajaxReturn('error');
    	}
    }
    
    public function insertPerson(){
    	$personModel = M('person');
    	if ($personModel->create()){
    		if ($personModel->add()){
    			$this->ajaxReturn('success');
    			return ;
    		}
    	}
    	$this->ajaxReturn('error');
    }
}